package com.tpshion.deploy.handler.msg.support;

import com.tpshion.deploy.common.support.BusinessException;
import com.tpshion.deploy.handler.msg.AbstartMsgHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;

@Component
public class MsgHandlerFactory {

    @Autowired
    private List<AbstartMsgHandler> msgHandlerList;

    public AbstartMsgHandler getHandler(String type){
        for (AbstartMsgHandler msgHandler : msgHandlerList) {
            if(msgHandler.getType().equals(type)){
                return msgHandler;
            }
        }
        throw new BusinessException("没有找到消息处理器");
    }

}
